import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { fetchStudentList } from '../../api'
/**
 * 学生列表
 */
export default function StudentList({ page, ...props }) {

    const [list, setList] = useState([])

    const getList = async () => {
        const { data } = await fetchStudentList()
        setList(data.list)
    }

    useEffect(() => {
        getList()
    }, [])


    return (
        <div>
            {
                list.map(item => (
                    <div key={item.id}>{item.name}</div>
                ))
            }
        </div>
    )
}

StudentList.defaultProps = {
    page: 1
}

StudentList.propTypes = {
    page: PropTypes.number.isRequired
}